package com.wzy.gulimall.search.config;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 描述
 * 创建人    Wzy
 * 创建时间: 2020-05-13  17:20
 */

@Configuration
public class GulimallElasticSearchConfig {

    //    public void esRestClient() {
//        new RestHighLevelClient(RestClient.builder())
//    }
    @Bean
    public RestHighLevelClient restHighLevelClient() {
        RestClientBuilder builder = null;
        builder = RestClient.builder(new HttpHost("192.168.116.128", 9200, "http"));
        RestHighLevelClient restHighLevelClient = new RestHighLevelClient(builder);
        return restHighLevelClient;

    }

    public static final RequestOptions COMMON_oPTIONS;

    static {
        RequestOptions.Builder builder = RequestOptions.DEFAULT.toBuilder();
        COMMON_oPTIONS = builder.build();
    }

}
